import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import View from './views/bbs/View.vue'
import BbsIndex from '@/views/bbs/Index.vue'
import BbsList from '@/views/bbs/List.vue'
import BbsAdd from '@/views/bbs/Add.vue'
import CareIndex from '@/views/care/Index.vue'
import BbsGroup from '@/components/home/BbsGroup.vue'
import BbsListBox from '@/components/home/BbsListBox.vue'
import UserIndex from './views/user/Index.vue'

Vue.use(Router)

export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  saveScrollPosition: true,
  transitionOnLoad: true,
  routes: [
    {
      path: '/',
      name: 'home',
      component: Home,
      children: [{
        path: '',
        redirect: 'bbsGroup'
      }, {
        path: 'bbsGroup',
        keepAlive: true,
        component: BbsGroup,
        children: [{
          path: '',
          redirect: 'bbsListBox'
        }, {
          path: 'bbsListBox',
          keepAlive: true,
          component: BbsListBox
        }]
      }, {
        path: 'bbs',
        component: BbsIndex
      }, {
        path: 'care',
        component: CareIndex
      },
      {
        // 用户中心
        path: 'my',
        component: UserIndex
        // component: Home
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
      }]
    },
    {
      path: '/bbs/view',
      component: View
    },
    {
      path: '/bbs/list',
      component: BbsList
    },
    {
      path: '/bbs/add',
      component: BbsAdd
    }
  ]
})
